package com.hsogoo.ultraman.enums;

import org.apache.commons.lang.StringUtils;

/**
 * Created by za-huangsaigang on 2018/9/13.
 */
public enum ConfigFileType {

    Properties("properties"),
    XML("xml"),
    JSON("json"),

    ;

    private String value;

    private ConfigFileType(String value) {
        this.value = value;
    }

    public String getValue() {
        return this.value;
    }

    public static ConfigFileType fromString(String value) {
        if (StringUtils.isEmpty(value)) {
            throw new IllegalArgumentException("value can not be empty");
        } else {
            if ("properties".equals(value)) {
                return Properties;
            }
            if ("xml".equals(value)) {
                return XML;
            }
            if ("json".equals(value)) {
                return JSON;
            }
        }
        throw new IllegalArgumentException(value + " not match ConfigFileType");
    }

}
